#include <chrono>

#include <net/tcp_client.h>
#include <login.pb.h>

void DoAuthRsp(TcpConn *c, const msg::AuthRsp &rsp) {
}

int main() {

    TcpClient client;
    client.Register<msg::AuthRsp>(msg::LOGIN_PROTO_AUTH_RSP, DoAuthRsp);
    client.Connect("127.0.0.1", 8888);

    std::thread([&client]() {
        while (true) {
            msg::AuthReq req;
            req.set_auth_code("xxxxxx");
            client.Conn()->Send(msg::LOGIN_PROTO_AUTH_REQ, req);
            std::this_thread::sleep_for(std::chrono::seconds(1));
            static int count = 0;
            ++count;
            if (count >= 10) {
                break;
            }
        }

    }).detach();

    while (client.Run()) { }

}


